package com.example.wanxiang.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Past;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 文章表
 */

@Data
@Document(collection = "articles")
public class Article {

    @Id
    private String id;

    @NotBlank
    private String title;

    @NotBlank
    private String content;

    @NotBlank
    private String author;

    @NotBlank
    private String type ;

    @NotBlank
    private Long userId ;

    @Past
    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE,fallbackPatterns = "yyyy-MM-dd")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
    @Temporal(TemporalType.DATE)
    private LocalDateTime authorCreatedTime;

    private Long visits ;

    private Boolean state;

    private List<String> imageIds;

}